xen.git
14 years agotools/hotplug: support vif-post.d hook arrangements
W. Michael Petullo [Wed, 25 May 2011 09:45:24 +0000 (10:45 +0100)]
tools/hotplug: support vif-post.d hook arrangements

New feature: you can drop hook scripts into
 /etc/xen/scripts/vif-post.d/*.hook

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: fix initialization of the disk parsing iterator
Stefano Stabellini [Tue, 24 May 2011 17:33:06 +0000 (18:33 +0100)]
libxl: fix initialization of the disk parsing iterator

Fix the initialization of the disk parsing iterator.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: refactor libxl__domain_firmware to choose based on
Ian Campbell [Tue, 24 May 2011 17:27:50 +0000 (18:27 +0100)]
libxl: refactor libxl__domain_firmware to choose based on
device_model_version

Note that the default remains "hvmloader" in both cases, this just
clarifies the intent for now.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: fixup error handling in libxl__build_hvm.
Ian Campbell [Tue, 24 May 2011 17:26:47 +0000 (18:26 +0100)]
libxl: fixup error handling in libxl__build_hvm.

We first pointless initialise rc and immediately overwrite the value, then fail
to return it on error anyway...

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: pass device model info down into HVM domain build functions.
Ian Campbell [Tue, 24 May 2011 17:25:56 +0000 (18:25 +0100)]
libxl: pass device model info down into HVM domain build functions.

The builder will soon need to know the device model version in order to select
the correct firmware.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl/xl: Use "firmware" rather than "hvmloader" in API.
Ian Campbell [Tue, 24 May 2011 17:24:58 +0000 (18:24 +0100)]
libxl/xl: Use "firmware" rather than "hvmloader" in API.

23251:0710f53cef4a turned build_info.kernel into
build_info.hvm.hvmloader however this is a rather specific name for a
field which may be used to load things which aren't hvmloader in the
future. Switch to calling the field and associated configuration itmes
"firmware" instead.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agotools: libxc: allow HVM firmware to be loaded at an arbitrary alignment
Ian Campbell [Tue, 24 May 2011 17:24:05 +0000 (18:24 +0100)]
tools: libxc: allow HVM firmware to be loaded at an arbitrary alignment

Enables direct loading of e.g. seabios.elf.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agotools: libxl: constify parameter to libxl__abs_path
Ian Campbell [Tue, 24 May 2011 17:22:23 +0000 (18:22 +0100)]
tools: libxl: constify parameter to libxl__abs_path

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agotools: libxc: enable libelf logging for HVM domain builder.
Ian Campbell [Tue, 24 May 2011 17:21:45 +0000 (18:21 +0100)]
tools: libxc: enable libelf logging for HVM domain builder.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>:
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agopygrub: XFS support for pygrub
Marco Nenciarini [Tue, 24 May 2011 17:11:24 +0000 (18:11 +0100)]
pygrub: XFS support for pygrub

Signed-off-by: Marco Nenciarini <marco.nenciarini@devise.it>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agotools: ocaml: remove non-posix-ism from sed script.
Ian Campbell [Tue, 24 May 2011 16:52:02 +0000 (17:52 +0100)]
tools: ocaml: remove non-posix-ism from sed script.

Christoph Egger reported than on NetBSD the build fails with

Parsing tools/ocaml/libs/xl/../../../../tools/libxl/libxl.idl
sed: 1: "1i(*\
  * AUTO-GENERATED ...": command i expects \ followed by test
gmake[7]: Leaving directory `tools/ocaml/libs/xl'

The following was tested by Christoph on NetBSD and also with GNU-sed
with and without the --posix flag.

In addition when sed fails will still create the output file, which confuses
subsequent make invocations. Generate to a temporary file and move into place
only on success.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxc: save: move static stats variable to stack variable.
Ian Campbell [Tue, 24 May 2011 09:14:10 +0000 (10:14 +0100)]
libxc: save: move static stats variable to stack variable.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agolibxc: save: don't bother calculating stat's deltas unless we are going to print...
Ian Campbell [Tue, 24 May 2011 09:14:10 +0000 (10:14 +0100)]
libxc: save: don't bother calculating stat's deltas unless we are going to print them

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agolibxc: save: encapsulate time stats in a struct
Ian Campbell [Tue, 24 May 2011 09:14:10 +0000 (10:14 +0100)]
libxc: save: encapsulate time stats in a struct

As a precursor to making non-static.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agolibxc: save: move static "write_count" variable into outbuf.
Ian Campbell [Tue, 24 May 2011 09:14:10 +0000 (10:14 +0100)]
libxc: save: move static "write_count" variable into outbuf.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agolibxc: save: noncached write doesn't use live parameter.
Ian Campbell [Tue, 24 May 2011 09:14:10 +0000 (10:14 +0100)]
libxc: save: noncached write doesn't use live parameter.

so drop it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agolibxc: save: rename ratewrite to uncached.
Ian Campbell [Tue, 24 May 2011 09:14:10 +0000 (10:14 +0100)]
libxc: save: rename ratewrite to uncached.

It doesn't do any ratelimiting...

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agolibxc: save: drop code under ADAPTIVE_SAVE ifdef.
Ian Campbell [Tue, 24 May 2011 09:14:10 +0000 (10:14 +0100)]
libxc: save: drop code under ADAPTIVE_SAVE ifdef.

The ifdef was added in 2005 (7702:b3c2bc39d815) but, as far as I can see, was
never enabled by default. Dropping it will help untangle some macros redefining
functions etc.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
14 years agolibxc: save/restore: remove static context variables
Ian Campbell [Tue, 24 May 2011 09:14:10 +0000 (10:14 +0100)]
libxc: save/restore: remove static context variables

20544:ad9d75d74bd5 and 20545:cc7d66ba0dad seemingly intended to change these
global static variables into stack variables but didn't remove the static
qualifier.

Also zero the entire struct once with memset rather than clearing fields
piecemeal in two different places.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
14 years agolibxl: libxl__xs_write format string should be const.
Ian Campbell [Tue, 24 May 2011 16:12:27 +0000 (17:12 +0100)]
libxl: libxl__xs_write format string should be const.

George Dunlap reports that gcc 4.4.3 complains:
  libxl_dm.c: In function libxl__create_device_mode:
  libxl_dm.c:776: error: format not a string literal and no format arguments
And indeed the format argument here is a char * from libxl__domain_bios().

Make the argument to libxl__xs_write a const char * and change
libxl__domain_bios to return a const char too.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: don't close file descriptors 4..255 in libxl__exec
Ian Campbell [Tue, 24 May 2011 15:18:19 +0000 (16:18 +0100)]
libxl: don't close file descriptors 4..255 in libxl__exec

It prevents callers from deliberately passing file descriptors to the child,
hides any callers who erroneously do so and doesn't deal with all file
descriptors in any case.

Rather than remove it all together replace it with some debug code
which checks for open file handles which do not have either O_CLOEXEC
or FD_CLOEXEC set. To enable the debug set _LIBXL_DEBUG_EXEC_FDS=1 to
print any open and non-CLOEXEC non-stdio FDs just before libxl__exec
actualy calls exec. Set _LIBXL_DEBUG_EXEC_FDS=2 to abort if any of
these exist.

On the basis of this debugging fix some leaked filehandles:
  * The read end of the pipe used to wake the parent from the
    intermediate process during libxl__spawn_spawn was leaked into the
    intermediate process.
  * The file descriptor representing the xl lock was not marked
    O_CLOEXEC (the lock itself is already specified to not be
    inherited across a fork).
  * The file descriptors passed to libxl__exec to be dup'd as
    std{in,out,err} were leaked at their original number. They are
    harmless (an attacker can just as easily use fd 0..2) but close
    anyway since it removes a case which a person evaluating open fd's
    needs to consider.
  * libxl_run_bootloader was leaking the xenconsole pty master into
    the bootloader child process.
  * If the bootloader fails to get as far as opening its end of the
    FIFO then we can also hang, check that the process has not exited
    as part of that loop. (we actually block opening the FIFO too so
    this is only a partial fix for the case where the bootlader has
    crashed quickly).

With these fixes I have tested that device models, bootloaders
(pygrub) and vncviewers which are spawned via libxl__exec with no
unexpected file descriptors open, at least in my configuration.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: improve logging on failure to start device model.
Ian Campbell [Tue, 24 May 2011 15:15:53 +0000 (16:15 +0100)]
libxl: improve logging on failure to start device model.

Distinguish between device model dying during startup (libxl__spawn_check
returns failure) and timing out while waiting for the xenstore node to show up.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agoremus: write circumlocution for try..except..finally
Jinsong Liu [Tue, 24 May 2011 15:12:25 +0000 (16:12 +0100)]
remus: write circumlocution for try..except..finally

Parsing /otc/source/vtd/xen-unstable/tools/python/../../tools/libxl/libxl.idl
  File "/usr/lib64/python2.4/site-packages/xen/remus/save.py", line 169
    finally:
          ^
SyntaxError: invalid syntax

This was introduced in 23195:13ec53a59a42
It is a problem for Python 2.4 and earlier, only.

So use try...(try...except)...finally as suggested by Ian Campbell.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Acked-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
Acked-by: Ian Campbell <Ian.Campbell@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: add statup checks to libxl__wait_for_device_model
Ian Campbell [Tue, 24 May 2011 14:57:24 +0000 (15:57 +0100)]
libxl: add statup checks to libxl__wait_for_device_model

When the device model is starting up push checks for spawn failure down into
libxl__wait_for_device_model, allowing us to fail more quickly when the device
model fails to start (e.g. due to a missing library or an early setup error
etc).

In order to allow the select loop in libxl__wait_for_device_model to wake when
the child dies add pipe between the parent and the intermediate process which
the intermediate process can use to signal the parent.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: pass libxl__spawn_starting to libxl__spawn_spawn.
Ian Campbell [Tue, 24 May 2011 14:21:26 +0000 (15:21 +0100)]
libxl: pass libxl__spawn_starting to libxl__spawn_spawn.

Passing a libxl__device_model_starting to a generic function and expecting it
to scrobble inside for the generic data structure is a strange interface.
Instead pass in a libxl__spawn_starting and an opaque hook data pointer.

The for_spawn member of libxl__device_model_starting was annotated with
"first!", suggesting that someone intended to use pointer casting tricks to
move between the outer and inner struct. However the field is a pointer not a
inline struct so this doesn't work (and it isn't used this way anyhow). Remove
the comment, and move the field away from the front for good measure.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: remove redundant call to libxl_domain_device_model
Ian Campbell [Tue, 24 May 2011 14:17:07 +0000 (15:17 +0100)]
libxl: remove redundant call to libxl_domain_device_model

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: check that device model binary is executable.
Ian Campbell [Tue, 24 May 2011 14:15:27 +0000 (15:15 +0100)]
libxl: check that device model binary is executable.

This causes us to fail more quickly in more obvious failure case of not
having the right binary installed.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxc: obtain correct length of p2m during core dumping
Markus Gross [Tue, 24 May 2011 14:00:16 +0000 (15:00 +0100)]
libxc: obtain correct length of p2m during core dumping

while implementing core dumping functionality for the libxl driver
of libvirt, I discovered an issue with mapping pages of a pv guest.

After dumping the core of a pv guest the domain was not cleared up
properly and some pages were not unmapped. This issue is similar
to the one reported here:
http://lists.xensource.com/archives/html/xen-devel/2011-05/msg01314.html

In xc_domain_dumpcore_via_callback in the file xc_core.c the function
xc_core_arch_map_p2m is called to map P2M_FL_ENTRIES pages to the variable p2m.
But to unmap the pages later, the dinfo->p2m_size has to be set accordingly.
This was not done, instead a variable named p2m_size was set.
This way P2M_FL_ENTRIES was always zero and the pages were left mapped.

[ This change should be considered for backport to relevant trees. ]

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxc: after saving, unmap correct amount for live_m2p
Jim Fehlig [Tue, 24 May 2011 13:50:00 +0000 (14:50 +0100)]
libxc: after saving, unmap correct amount for live_m2p

With some help from Olaf, I've finally got to the bottom of an issue I
came across while trying to implement save/restore in the libvirt
libxenlight driver.  After issuing the save operation, the saved domain
was not being cleaned up properly and left in this state from xl's
perspective

xen33:# xl list
Name                   ID   Mem VCPUs      State   Time(s)
Domain-0                0  6821     8     r-----     122.5
(null)                  2     2     2     --pssd      10.8

Checking the libvirtd /proc/$pid/maps I found this

7f3798984000-7f3798b86000 r--s 00002000 00:03 4026532097 /proc/xen/privcmd

So not all all pages belonging to the domain were unmapped from
libvirtd.  In tools/libxc/xc_domain_save.c we found that P2M_FL_ENTRIES
were being mapped but only P2M_FLL_ENTRIES were being unmapped.  The
attached patch changes the unmapping to use the same P2M_FL_ENTRIES
macro.  I'm not too familiar with this code though so posting here for
review.

I suspect this was not noticed before since most (all?) processes doing
save terminate after the save and are not long-running like libvirtd.

Ian Campbell writes:
> Looks like I introduced this in 18558:ccf0205255e1, sorry!
>
> I guess it is also wrong in the error path out of map_and_save_p2m_table
> and so we also need [another hunk].

This change should be backported to relevant earlier trees. -iwj

From: Jim Fehlig <jfehlig@novell.com>
From: Ian Campbell <Ian.Campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agox86/mm: Fix one more check in the EPT p2m code
Tim Deegan [Tue, 24 May 2011 08:30:51 +0000 (09:30 +0100)]
x86/mm: Fix one more check in the EPT p2m code

This is one more place that needs to check for 0 entries
after the AMD p2m-sharing patch made p2m_ram_rw == 0

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agodrivers/passthrough: fix error paths in pci_add_device*()
Tim Deegan [Mon, 23 May 2011 17:35:32 +0000 (18:35 +0100)]
drivers/passthrough: fix error paths in pci_add_device*()

When a device can't be allocated to dom0 by the IOMMU, don't leave
dom0 in the "domain" field.  It causes pci_remove_device()
to crash trying to remove the dev from the domain's list of devices
(and was probably the wrong thing to do anyway).

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agodrivers/passthrough: Revert 23352:ea48976517af -- incorrect bugfix.
Keir Fraser [Mon, 23 May 2011 17:35:04 +0000 (18:35 +0100)]
drivers/passthrough: Revert 23352:ea48976517af -- incorrect bugfix.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agoFix Config.mk's cc-option for -Wno-* options.
Keir Fraser [Mon, 23 May 2011 16:38:28 +0000 (17:38 +0100)]
Fix Config.mk's cc-option for -Wno-* options.

These disable-warning options are handled specially by GCC:
 (a) they are ignored unless the compiler emits a warning; and
 (b) even then they produce a warning rather than an error

To handle this, modify the test invocation of GCC to compile a
fragment of code that will always provoke a warning (integer assigned
to pointer). This works around (a) above.

Then, we grep the compiler's stdout/stderr for the option-under-test,
the presence of which would indicate an "unrecognized command-line
option" warning/error. This works around (b) above, letting us
distinguish between the "integer assigned to pointer" and
"unrecognized command-line option" warnings.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agogcc-4.6 compile fix: build with -Wno-unused-but-set-variable
Olaf Hering [Sat, 21 May 2011 06:55:46 +0000 (07:55 +0100)]
gcc-4.6 compile fix: build with -Wno-unused-but-set-variable

Avoid "error: variable 'unused' set but not used
[-Werror=unused-but-set-variable]" with gcc 4.6.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
14 years agotools: Fix build failure with gcc 4.4.3-4ubuntu5
George Dunlap [Fri, 20 May 2011 17:20:09 +0000 (18:20 +0100)]
tools: Fix build failure with gcc 4.4.3-4ubuntu5

c/s 23253:a3db6b91f32d causes build failure with gcc 4.4.3-4ubuntu5,
as the compiler can't figure out that the value returned is always
a string literal.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
14 years agolibxl: turn some stray printf's in libxl into LIBXL__LOG.
Ian Campbell [Fri, 20 May 2011 17:12:41 +0000 (18:12 +0100)]
libxl: turn some stray printf's in libxl into LIBXL__LOG.

Appear to have been leftover from when the domain create stuff was
pushed down from xl into the library.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agohotplug: fix busy loop device detection
Olaf Hering [Fri, 20 May 2011 17:09:26 +0000 (18:09 +0100)]
hotplug: fix busy loop device detection

Improve busy loop device detection after changeset 22773:02c0af2bf280

The intention is not to find the file to be mounted in the losetup -a
output.  What matters are existing mounted files with the same dev:inode
as the new file.  So the fix is to apply variable expansion which
happens only without double quotes.  Otherwise $dev will contain
newlines for hardlinked files, as mentioned in the commit message from
the changeset above.

losetup -a does also truncate long filenames to 62 chars due to ioctl
limitations.  This part is fixed with 2.6.37 where the filename can be
obtained from sysfs. As a result very long filenames will be missed.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: make it possible to disable vnc
Zhou Peng [Fri, 20 May 2011 15:11:13 +0000 (16:11 +0100)]
libxl: make it possible to disable vnc

tools/libxl/libxl__build_device_model_args_new/old: The condition is
so rigorous that user has no chance to disable the vnc,
considering what has been done in parse_config_data() by default,
which is not resonable with vnc option in vm-cfg file.

I think, If user explicitly set "vnc=0", vnc should be disabled.
User should have the chance to only use sdl, other remote
display(spice) and even nothing.

Signed-off-by: Zhou Peng <zhoupeng@nfs.iscas.ac.cn>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agoxen: Include headers that are actually needed, drop everything else.
Christoph Egger [Fri, 20 May 2011 14:39:07 +0000 (15:39 +0100)]
xen: Include headers that are actually needed, drop everything else.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
14 years agox86/mca: Fix debug output.
Liu, Jinsong [Fri, 20 May 2011 12:42:23 +0000 (13:42 +0100)]
x86/mca: Fix debug output.

At x86_mcinfo_dump(), a little bug at printk information,
illusively= indicate an CMCI/POLLED error to a MCE error, this will
make debug confusing.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
14 years agoRemove unused var from acpi_idle_do_entry().
Keir Fraser [Fri, 20 May 2011 08:44:41 +0000 (09:44 +0100)]
Remove unused var from acpi_idle_do_entry().

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agoxen: Remove some initialised but otherwise unused variables.
Olaf Hering [Fri, 20 May 2011 08:33:53 +0000 (09:33 +0100)]
xen: Remove some initialised but otherwise unused variables.

Fixes the build under gcc-4.6 -Werror=unused-but-set-variable

Signed-off-by: Olaf Hering <olaf@aepfle.de>
14 years agogcc-4.6 compile fix: tools/libxc/xc_domain_restore.c
Olaf Hering [Fri, 20 May 2011 08:18:17 +0000 (09:18 +0100)]
gcc-4.6 compile fix: tools/libxc/xc_domain_restore.c

xc_domain_restore.c: In function 'xc_domain_restore':
xc_domain_restore.c:1090:18: error: variable 'prev_pc' set but not
used [-Werror=unused-but-set-variable]

Signed-off-by: Olaf Hering <olaf@aepfle.de>
14 years agogcc-4.6 compile fix: tools/libxc/xc_tmem.c
Olaf Hering [Fri, 20 May 2011 08:17:46 +0000 (09:17 +0100)]
gcc-4.6 compile fix: tools/libxc/xc_tmem.c

xc_tmem.c: In function 'xc_tmem_restore':
xc_tmem.c:393:14: error: variable 'save_max_pools' set but not used
[-Werror=unused-but-set-variable]

Signed-off-by: Olaf Hering <olaf@aepfle.de>
14 years agohvmloader: always include HPET table
Paolo Bonzini [Fri, 20 May 2011 08:15:40 +0000 (09:15 +0100)]
hvmloader: always include HPET table

Windows SVVP tests require an HPET table even if the HPET is disabled.
This makes sense since the HPET _is_ in the DSDT and, while the OS
does not know that, in principle it's status may change.

(For what it's worth SeaBIOS, in addition to doing this, totally
ignores QEMU's -no-hpet flag and always reports 0x0f for the HPET's
_STA method).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86/AMD: don't set ARAT feature flag on family F CPUs
Jan Beulich [Fri, 20 May 2011 08:11:54 +0000 (09:11 +0100)]
x86/AMD: don't set ARAT feature flag on family F CPUs

Following Linux commit 14fb57dccb6e1defe9f89a66f548fcb24c374c1d from
Borislav Petkov.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agonestedsvm: reduce TLB flushes
Keir Fraser [Fri, 20 May 2011 08:07:54 +0000 (09:07 +0100)]
nestedsvm: reduce TLB flushes

Reduce TLB flushes:
1. When we update the cr3 during VMRUN/VMEXIT emulation
    we toggle between n1asid and n2asid forth and back
    => no TLB flush needed
2. Only flush n1asid or n2asid depending on vcpu guest mode
    and not both unconditionally.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir@xen.org>
14 years agonestedsvm: reduce TLB flushes
Keir Fraser [Fri, 20 May 2011 08:06:58 +0000 (09:06 +0100)]
nestedsvm: reduce TLB flushes

Reduce TLB flushes:
1. When we update the cr3 during VMRUN/VMEXIT emulation
    we toggle between n1asid and n2asid forth and back
    => no TLB flush needed
2. Only flush n1asid or n2asid depending on vcpu guest mode
    and not both unconditionally.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86: clear CPUID output of leaf 0xd for Dom0 when xsave is disabled
Jan Beulich [Fri, 20 May 2011 07:54:45 +0000 (08:54 +0100)]
x86: clear CPUID output of leaf 0xd for Dom0 when xsave is disabled

Linux starting with 2.6.36 uses the XSAVEOPT instruction and has
certain code paths that look only at the feature bit reported through
CPUID leaf 0xd sub-leaf 1 (i.e. without qualifying the check with one
evaluating leaf 4 output). Consequently the hypervisor ought to mimic
actual hardware in clearing leaf 0xd output when not supporting xsave.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agopci_remove_device: fix linked list discipline
Tim Deegan [Fri, 20 May 2011 07:52:22 +0000 (08:52 +0100)]
pci_remove_device: fix linked list discipline

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoMakefile: install-tools does not depend on ioemu-dir if CONFIG_IOEMU=n
Keir Fraser [Fri, 20 May 2011 07:48:33 +0000 (08:48 +0100)]
Makefile: install-tools does not depend on ioemu-dir if CONFIG_IOEMU=n

Based on patch by George Dunlap.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agotools: xl: add option to run in foreground but still monitor for reboot etc
Ian Campbell [Tue, 17 May 2011 16:32:19 +0000 (17:32 +0100)]
tools: xl: add option to run in foreground but still monitor for reboot etc

Split daemonization option out from monitoring a domain for reboot
etc. The 'e' option continues to disable both and a new 'F'(oreground)
option disables only daemonization.

When I'm debugging xl in the foreground this is often the behaviour I
would like.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agolibxl: Fix apic/acpi confusion
Ian Jackson [Tue, 17 May 2011 16:28:12 +0000 (17:28 +0100)]
libxl: Fix apic/acpi confusion

"apic" was written a couple of times where "acpi" was meant.

Signed-off-by: Zhou Peng <zhoupeng@nfs.iscas.ac.cn>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@eu.citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agox86: further adjustments to arch_set_info_guest() after c/s 23142:f5e8d152a565
Jan Beulich [Tue, 17 May 2011 12:55:45 +0000 (13:55 +0100)]
x86: further adjustments to arch_set_info_guest() after c/s 23142:f5e8d152a565

The adjustments to v->arch.user_regs.eflags and the initialization of
the int80 direct trap must be done earlier (namely before the function
may bail because of inconsistencies between input and stored state on
an already initialised vCPU) so that stored state is consistent, and
for arch_get_info_guest() to not have its eflags related BUG_ON()
triggered.

Further, v->arch.pv_vcpu.ctrlreg[] indices 3 and 1 aren't being kept
up to date while the domain is running, so consistency checks must
instead be done against v->arch.guest_table{,_user}.

Additionally, for 64-bit pv domains, CR1 must also be checked to be
consistent with the kernel mode setting for the vCPU, and the whole
CR1 checking should not be done for 32-bit pv domains.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agoBuild target to wrap dist/install in a .deb archive.
Tim Deegan [Mon, 16 May 2011 12:34:25 +0000 (13:34 +0100)]
Build target to wrap dist/install in a .deb archive.

Adds "make deb", which does a "make dist" build and wraps the
resulting dist/install files in dist/xen-<version>.deb

This is _not_ a "packaged" version of Xen for Debian users, nor is it
intended to compete with anyone else's packaging efforts.  In
particular it doesn't do any of the boot-time or fstab fixups needed
to actually start the xen tools.  It's just a quick hack for
developers to be able to quickly install and uninstall a Xen build on
a test box.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agoamd-iommu: two more __init annotations
Jan Beulich [Mon, 16 May 2011 12:33:10 +0000 (13:33 +0100)]
amd-iommu: two more __init annotations

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agox86-64: remove left over uses of .got entries
Jan Beulich [Mon, 16 May 2011 12:32:37 +0000 (13:32 +0100)]
x86-64: remove left over uses of .got entries

These were caused by some declarations happening before the compiler
would have seen the visibility pragma.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agonestedsvm: fix fpu context switch
Christoph Egger [Mon, 16 May 2011 12:31:42 +0000 (13:31 +0100)]
nestedsvm: fix fpu context switch

Two different vmcb's are used to run l1 guest and l2 guest.
When host xen switches physical FPU to a different cpu while
l1 or l2 guest is running we need to sync CR0.TS bit in the
other vmcb.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Reviewed-by: Uwe Dannowski <Uwe.Dannowski@amd.com>
Reviewed-by: Wei Huang <Wei.Huang2@amd.com>
14 years agoVT-d: Fix resource leaks on error paths
Igor Mammedov [Mon, 16 May 2011 12:29:24 +0000 (13:29 +0100)]
VT-d: Fix resource leaks on error paths

On error exit from functions, maped pages should be unmapped
and acquired locks released.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Allen Kay <allen.m.kay@intel.com>
14 years agox86/tsc: Remove incorrect assertion from cstate_restore_tsc()...
Keir Fraser [Mon, 16 May 2011 12:24:05 +0000 (13:24 +0100)]
x86/tsc: Remove incorrect assertion from cstate_restore_tsc()...

..fix and move to write_tsc().

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86/ioapic: avoid gcc 4.6 warnings about uninitialised variables
Ian Campbell [Mon, 16 May 2011 12:13:41 +0000 (13:13 +0100)]
x86/ioapic: avoid gcc 4.6 warnings about uninitialised variables

gcc 4.6 complains:
        io_apic.c: In function 'restore_IO_APIC_setup':
        /build/user-xen_4.1.0-3-amd64-zSon7K/xen-4.1.0/debian/build/build-hypervisor_amd64_amd64/xen/include/asm/io_apic.h:150:26:
        error: '*((void *)&entry+4)' may be used uninitialized in this
        function [-Werror=uninitialized]
        io_apic.c:221:32: note: '*((void *)&entry+4)' was declared
        here
        /build/user-xen_4.1.0-3-amd64-zSon7K/xen-4.1.0/debian/build/build-hypervisor_amd64_amd64/xen/include/asm/io_apic.h:150:26:
        error: 'entry' may be used uninitialized in this function
        [-Werror=uninitialized]
        io_apic.c:221:32: note: 'entry' was declared here
        cc1: all warnings being treated as errors

Add functions to read/write an entire IO APIC entry using an explicit
union to allow gcc to spot the initialisation.

Reported as Debian bug #625438, thanks to Matthias Klose.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@novell.com>
14 years agox86/mca: simplify mce action, and some update of mem err handler for
Liu, Jinsong [Mon, 16 May 2011 12:12:03 +0000 (13:12 +0100)]
x86/mca: simplify mce action, and some update of mem err handler for
future SRAR extension

This patch simplify mce_action(). Basically the 2 set of mce status
flags MCA_... and MCER_... are highly functional similar. This patch
remove the redundant middle-level flag MCA_..., and its related data
structure and function, so that mce_action() logic is more clean and
simpler.  This patch also update mem err
handler. intel_memerr_dhandler() will be commonly used by SRAO and
SRAR, so for the extension of future SRAR case, this patch remove the
default fail flag from intel_memerr_dhandler() outside to SRAO/SRAR
level, since only SRAO/SRAR handler itself has the knowledge of how to
handle the failure when mem err handler fail.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
14 years agox86: Check for valid pirq values in hvm_domain_use_pirq
Stefano Stabellini [Thu, 12 May 2011 15:42:54 +0000 (16:42 +0100)]
x86: Check for valid pirq values in hvm_domain_use_pirq

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
14 years agovt-d: [CVE-2011-1898] Ensure that "iommu=required" enables interrupt remapping.
Keir Fraser [Thu, 12 May 2011 15:42:00 +0000 (16:42 +0100)]
vt-d: [CVE-2011-1898] Ensure that "iommu=required" enables interrupt remapping.

Ensure that when Xen boots with "iommu=required" it will also insist
that interrupt remapping is supported and enabled.  It arranges that
booting with that option on vulnerable hardware will fail, rather than
appearing to succeed but actually being vulnerable to guests.

From: Allen Kay <allen.m.kay@intel.com>
Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86, vtd: [CVE-2011-1898] Protect against malicious MSIs from untrusted devices.
Keir Fraser [Thu, 12 May 2011 15:39:31 +0000 (16:39 +0100)]
x86, vtd: [CVE-2011-1898] Protect against malicious MSIs from untrusted devices.

In the absence of VT-d interrupt remapping support, a device can send
arbitrary APIC messages to host CPUs. One class of attack that results
is to confuse the hypervisor by delivering asynchronous interrupts to
vectors that are expected to handle only synchronous
traps/exceptions.

We block this class of attack by:
(1) setting APIC.TPR=0x10, to block all interrupts below vector
0x20. This blocks delivery to all architectural exception vectors.
(2) checking APIC.ISR[vec] for vectors 0x80 (fast syscall) and 0x82
(hypercall). In these cases we BUG if we detect we are handling a
hardware interrupt -- turning a potentially more severe infiltration
into a straightforward system crash (i.e, DoS).

Thanks to Invisible Things Lab <http://www.invisiblethingslab.com>
for discovery and detailed investigation of this attack.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86/hvm: Use UNLIKELY_{START,END} in a few suitable places in asm.
Keir Fraser [Thu, 12 May 2011 08:33:59 +0000 (09:33 +0100)]
x86/hvm: Use UNLIKELY_{START,END} in a few suitable places in asm.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86/hvm: pv-on-hvm: fix de/assert_irq checks
Stefano Stabellini [Thu, 12 May 2011 08:15:05 +0000 (09:15 +0100)]
x86/hvm: pv-on-hvm: fix de/assert_irq checks

The checks in assert_irq and deassert_irq to distinguish interrupts
that have been remapped onto event channels from the others that have
to be injected using the emulated lapic are wrong.

Fix the condition checks using the convenient hvm_domain_use_pirq
function.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
14 years agohvm: vpmu: Enable HVM VPMU for AMD Family 12h and 14h processors
Jacob Shin [Thu, 12 May 2011 08:14:06 +0000 (09:14 +0100)]
hvm: vpmu: Enable HVM VPMU for AMD Family 12h and 14h processors

HVM VPMU support can be enabled for AMD Family 12h and 14h processors
by taking the same code path as 10h.

Signed-off-by: Jacob Shin <jacob.shin@amd.com>
14 years agox86: use compat hypercall handlers for calls from 32-bit HVM guests
Tim Deegan [Thu, 12 May 2011 08:13:18 +0000 (09:13 +0100)]
x86: use compat hypercall handlers for calls from 32-bit HVM guests

On 64-bit Xen, hypercalls from 32-bit HVM guests are handled as
a special case, but not all the hypercalls are corrently redirected
to their compat-mode wrappers.  Use compat_* for xen_version,
sched_op and set_timer_op for consistency.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agonestedsvm: fix shadow-on-hap
Christoph Egger [Thu, 12 May 2011 08:07:35 +0000 (09:07 +0100)]
nestedsvm: fix shadow-on-hap

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agonestedsvm: update rip on invlpga intercept
Christoph Egger [Thu, 12 May 2011 08:00:46 +0000 (09:00 +0100)]
nestedsvm: update rip on invlpga intercept

Fixes endless loop.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
14 years agonestedsvm: fix error path when VMRUN emulation fails
Christoph Egger [Thu, 12 May 2011 07:58:02 +0000 (08:58 +0100)]
nestedsvm: fix error path when VMRUN emulation fails

With this, l1 guest keeps alive rather crashing the host.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agonestedsvm: fix host crash with pv-on-hvm Linux KVM guest
Christoph Egger [Thu, 12 May 2011 07:57:08 +0000 (08:57 +0100)]
nestedsvm: fix host crash with pv-on-hvm Linux KVM guest

Nested SVM was unaware of the HVM direct vector eventchn mechanism.
Attached patch fixes a host crash when starting a KVM L2 guest on a
pv-on-hvm L1 Linux guest (e.g., HVM Debian Squeeze domU).

Signed-off-by: Uwe Dannowski <Uwe.Dannowski@amd.com>
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agotools/xm-test: portability fix: Avoid using == in /bin/sh script
Christoph Egger [Thu, 12 May 2011 07:55:12 +0000 (08:55 +0100)]
tools/xm-test: portability fix: Avoid using == in /bin/sh script

From: David Brownlee <abs@netbsd.org>
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
14 years agox86/mca: MCA bank clear
Liu, Jinsong [Thu, 12 May 2011 07:53:42 +0000 (08:53 +0100)]
x86/mca: MCA bank clear

1). Add explicitly uc=pcc=1 fatal error detect, since under such case
the s/ar/over bits status is undefined and hence may be
mis-cleaned. Explicit fatal detect return 0 indicate stick MSR bank
will have chance to be handled after reboot by polling;
2). Fix a little bug for case SRAR, over bit should be 0 when need
clear bank, otherwise it would reset system;
3). When clear bank, add clear MCi_ADDR/MISC if it's valid, according
to Intel SDM;

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
14 years agox86/mca MCA minor bugfix
Liu, Jinsong [Thu, 12 May 2011 07:52:47 +0000 (08:52 +0100)]
x86/mca MCA minor bugfix

This patch fix a minor bug, when in xen context and cannot safely
return the mce break point, reset system;

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
14 years agox86/mca: MCA physical address check when calculate domain
Liu, Jinsong [Thu, 12 May 2011 07:52:18 +0000 (08:52 +0100)]
x86/mca: MCA physical address check when calculate domain

Bank addr maybe invalid, or Bank addr maybe physical/memory/linear
address or segment offset.  This patch add mca
MCi_STATUS_MISCV/MCi_STATUS_ADDRV check, and add physical address
verify, so that it work safe when calculate domain.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
14 years agoSimplify and build-fix (for some gcc versions) radix_tree_int_to_ptr().
Keir Fraser [Wed, 11 May 2011 11:58:04 +0000 (12:58 +0100)]
Simplify and build-fix (for some gcc versions) radix_tree_int_to_ptr().

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agox86/mm/p2m: break into common, pt-implementation and pod parts.
Tim Deegan [Fri, 6 May 2011 10:15:35 +0000 (11:15 +0100)]
x86/mm/p2m: break into common, pt-implementation and pod parts.

Start to make a clearer distinction between generic p2m functions and
the implementation of the datastructure as an x86 pagetable.
Also move the EPT datastructure implementation into x86/mm/ to match,
and split the PoD admin code into its own file.

This is just code motion, except for splitting the p2m_initialise
function into a pt-specific part and a common part.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
14 years agolibxc: [CVE-2011-1583] pv kernel image validation
Ian Jackson [Mon, 9 May 2011 14:00:57 +0000 (15:00 +0100)]
libxc: [CVE-2011-1583] pv kernel image validation

The functions which interpret the kernel image supplied for a
paravirtualised guest, and decompress it into memory when booting the
domain, are incautious.  Specifically:

 (i) Integer overflow in the decompression loop memory allocator might
    result in overrunning the buffer used for the decompressed image;
 (ii) Integer overflows and lack of checking of certain length fields
    can result in the loader reading its own address space beyond the
    size of the supplied kernel image file.
 (iii) Lack of error checking in the decompression loop can lead to an
    infinite loop.

This patch fixes these problems.

CVE-2011-1583.

Signed-off-by: Ian Campbell <Ian.Campbell@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 years agox86/mca: MCA handler extension
Liu, Jinsong [Mon, 9 May 2011 10:43:58 +0000 (11:43 +0100)]
x86/mca: MCA handler extension

Add intel_srao_check for future SRAR extension;
Add a wrapper to SRAO handler to make it more extensible for future
SRAO error-code types;

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
14 years agox86/mca: MCA trivial cleanup
Liu, Jinsong [Mon, 9 May 2011 10:43:26 +0000 (11:43 +0100)]
x86/mca: MCA trivial cleanup

1) A little cleanup for mce_action(), remove redundant input param;
2) result should be MCA_NEED_RESET instead of MCA_RESET, otherwise
system cannot reset when fatal;

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
14 years agox86/mca: MCA bank extension
Liu, Jinsong [Mon, 9 May 2011 10:42:45 +0000 (11:42 +0100)]
x86/mca: MCA bank extension

Current mca_summay use uint32_t as bitmask of bank uc/pcc/recoverable.
It's not extensible, support no more than 32 mca banks, while
according to Intel SDM, bank number could be as much as 256.

This patch use bool_t flag since it only need to record and indicate
the most severity case.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
14 years agox86/LWP: Add LWP support for SVM guests
Wei Huang [Mon, 9 May 2011 10:40:42 +0000 (11:40 +0100)]
x86/LWP: Add LWP support for SVM guests

This patch enables SVM to handle LWP related MSRs and CPUID. It
intercepts guests read/write to LWP_CFG. It also save/restore LWP_CFG
when guests touch this MSR. The LWP_CBADDR MSR is not intercepted
because this MSR is handled by xsave/xrstor.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
14 years agox86/LWP: export LWP related CPUID to AMD SVM guest
Wei Huang [Mon, 9 May 2011 10:40:05 +0000 (11:40 +0100)]
x86/LWP: export LWP related CPUID to AMD SVM guest

This patch exposes LWP CPUID 0x8000001C to SVM guests.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
14 years agox86/fpu: create lazy and non-lazy FPU restore functions
Wei Huang [Mon, 9 May 2011 10:39:23 +0000 (11:39 +0100)]
x86/fpu: create lazy and non-lazy FPU restore functions

Currently Xen relies on #NM (via CR0.TS) to trigger FPU context
restore. But not all FPU state is tracked by TS bit. This function
creates two FPU restore functions: vcpu_restore_fpu_lazy() and
vcpu_restore_fpu_eager(). vcpu_restore_fpu_lazy() is still used when
#NM is triggered. vcpu_restore_fpu_eager(), as a comparision, is
called for vcpu which is being scheduled in on every context
switch. To minimize restore overhead, it creates a flag,
nonlazy_xstate_used, to control non-lazy restore.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
14 years agox86/fpu: add mask parameter to xsave and xrstor
Wei Huang [Mon, 9 May 2011 10:38:55 +0000 (11:38 +0100)]
x86/fpu: add mask parameter to xsave and xrstor

Xen currently sets mask bits of xsave() and xrstor() to all 1's. This
patch adds a mask option to xsave() and xrstor().

Signed-off-by: Wei Huang <wei.huang2@amd.com>
14 years agox86/fpu: clean up FPU context restore function
Wei Huang [Mon, 9 May 2011 10:38:30 +0000 (11:38 +0100)]
x86/fpu: clean up FPU context restore function

This patch cleans up context restore function. It renames the function
name to vcpu_restore_fpu(). It also extracts FPU restore code (frstor,
fxrstor, xrstor) out into seperate functions. vcpu_restor_fpu() will
dispatch to these functions depending on CPU's capability.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
14 years agox86/fpu: clean up FPU context save function
Wei Huang [Mon, 9 May 2011 10:38:04 +0000 (11:38 +0100)]
x86/fpu: clean up FPU context save function

This patch cleans up context save function. It renames the save
function to vcpu_save_fpu() because existing function name is
confusion. It also extracts FPU context save code (fsave, fxsave,
xsave) into seperate functions. vcpu_save_fpu() will call
corresponding sub-function depending on CPU's capability.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
14 years agox86/fpu: create FPU init and destroy functions
Wei Huang [Mon, 9 May 2011 10:37:36 +0000 (11:37 +0100)]
x86/fpu: create FPU init and destroy functions

Extract FPU initialization and destroy code into two functions. These
functions handle memory allocation/deallocation for FPU context.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
14 years agox86/fpu: extract extended related code into xstate.h and xstate.c
Wei Huang [Mon, 9 May 2011 10:37:03 +0000 (11:37 +0100)]
x86/fpu: extract extended related code into xstate.h and xstate.c

Current extended code is mixing with FPU code in i387.c. As part of
FPU code cleanup, this patch moves all extended state code into
independent files. Not much semantic are changed and most function
names are kept untouched, except for xsave() and xsaveopt(). These two
functions are combined into a single function.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
14 years agoxentrace: Remove unneeded cast when assigning pointer value to dst
Olaf Hering [Mon, 9 May 2011 08:59:50 +0000 (09:59 +0100)]
xentrace: Remove unneeded cast when assigning pointer value to dst

Remove unneeded cast when assigning pointer value to dst.
Both arrays are uint32_t and memcpy takes a void pointer.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
14 years agoxentrace: Mark data_size __read_mostly because it's only written once
Olaf Hering [Mon, 9 May 2011 08:59:13 +0000 (09:59 +0100)]
xentrace: Mark data_size __read_mostly because it's only written once

Signed-off-by: Olaf Hering <olaf@aepfle.de>
14 years agoxentrace: Move the global variable t_info_first_offset into calculate_tbuf_size()
Olaf Hering [Mon, 9 May 2011 08:58:36 +0000 (09:58 +0100)]
xentrace: Move the global variable t_info_first_offset into calculate_tbuf_size()

Move the global variable t_info_first_offset into
calculate_tbuf_size() because it is only used there. Change the type
from u32 to uint32_t to match type in other places.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
14 years agotools/tests/xen-access: minor bug fixes
Aravindh Puthiyaparambil [Mon, 9 May 2011 08:56:39 +0000 (09:56 +0100)]
tools/tests/xen-access: minor bug fixes

Fix a couple of minor bugs in xen-access test program:
 * Fix -m option handling.
 * Fix a segfault that was occurring during program exit.

Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com>
14 years agohvm: vpmu: Add support for AMD Family 15h processors
Jacob Shin [Mon, 9 May 2011 08:54:46 +0000 (09:54 +0100)]
hvm: vpmu: Add support for AMD Family 15h processors

AMD Family 15h CPU mirrors legacy K7 performance monitor counters to
a new location, and adds 2 new counters. This patch updates HVM VPMU
to take advantage of the new counters.

Signed-off-by: Jacob Shin <jacob.shin@amd.com>
14 years agoxenoprof: Add support for AMD Family 15h processors
Jacob Shin [Mon, 9 May 2011 08:53:07 +0000 (09:53 +0100)]
xenoprof: Add support for AMD Family 15h processors

AMD Family 15h CPU mirrors legacy K7 performance monitor counters to
a new location, and adds 2 new counters. This patch updates xenoprof
to take advantage of the new counters.

Signed-off-by: Jacob Shin <jacob.shin@amd.com>
Rename fam15h -> amd_fam15h in a few places, as suggested by Jan
Beulich.

Signed-off-by: Keir Fraser <keir@xen.org>
14 years agoxenoprof: Update cpu_type to sync with upstream oprofile
Jacob Shin [Mon, 9 May 2011 08:49:14 +0000 (09:49 +0100)]
xenoprof: Update cpu_type to sync with upstream oprofile

Update xenoprof's cpu_type to match upstream oprofile. Currently AMD
Family 11h ~ Family 15h are broken due to string mismatches.

Signed-off-by: Jacob Shin <jacob.shin@amd.com>
14 years agomisc cpufreq cleanup
Jan Beulich [Mon, 9 May 2011 08:46:02 +0000 (09:46 +0100)]
misc cpufreq cleanup

- proper handling of governor command line options when using the
  default governor
- warning message for unrecognized command line options
- replacing a NR_CPUS sized array with per-CPU data
- a couple of __read_mostly annotations

Signed-off-by: Jan Beulich <jbeulich@novell.com>
14 years agox86: replace nr_irqs sized per-domain arrays with radix trees
Jan Beulich [Mon, 9 May 2011 08:27:42 +0000 (09:27 +0100)]
x86: replace nr_irqs sized per-domain arrays with radix trees

It would seem possible to fold the two trees into one (making e.g. the
emuirq bits stored in the upper half of the pointer), but I'm not
certain that's worth it as it would make deletion of entries more
cumbersome. Unless pirq-s and emuirq-s were mutually exclusive...

v2: Split setup/teardown into two stages - (de-)allocation (tree node
(de-)population) is done with just d->event_lock held (and hence
interrupts enabled), while actual insertion/removal of translation
data gets done with irq_desc's lock held (and interrupts disabled).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Fix up for new radix-tree implementation. In particular, we should
never insert NULL into a radix tree, as that means empty slot (which
can be reclaimed during a deletion). Make use of
radix_tree_int_to_ptr() (and its inverse) to hide some of these
details.

Signed-off-by: Keir Fraser <keir@xen.org>